package com.baozun.houji.me.activity.account

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.baozhun.mall.common.arouter.RoutePath
import com.baozhun.mall.common.base.BaseActivity
import com.baozhun.mall.common.util.eventbus.EventBusUtils
import com.baozhun.mall.common.util.eventbus.EventCode
import com.baozhun.mall.common.util.eventbus.EventMessage
import com.baozun.houji.me.R
import com.baozun.houji.me.databinding.ActivityRegisterBinding
import com.baozun.houji.me.viewmodel.RegisterViewModel
import com.jaeger.library.StatusBarUtil
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode


/**
 * @Title：注册页面
 * @Description：
 * @Author：xuefeng.zhu
 * @Since：2022/12/10
 * @Version：1.0.0
 */
@Route(path = RoutePath.Me.REGISTER)
class RegisterActivity : BaseActivity<RegisterViewModel, ActivityRegisterBinding>() {

    companion object {
        fun start(context: Context) {
            var intent = Intent(context, RegisterActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun initView(savedInstanceState: Bundle?) {
        EventBusUtils.register(this)
        StatusBarUtil.setColor(this, getColor(android.R.color.transparent))
        StatusBarUtil.setTransparentForImageView(this, mDataBinding.titleBarBack)
    }

    override fun onClick(v: View?) {
        super.onClick(v)
        when (v?.id) {
            R.id.title_bar_back -> {
                finish()
            }

            R.id.tv_register -> {
            }

            R.id.tv_login_hint -> {
                ARouter.getInstance().build(RoutePath.Me.LOGIN).navigation()
            }
        }
    }


    @Subscribe(threadMode = ThreadMode.MAIN)
    fun onMessageEvent(event: EventMessage<Any>) {
        if (event.eventCode == EventCode.LOGIN_SUCCESS) {
            finish()
        }
    }
}